package com.qdlc.p2p.dal.model;

import org.springframework.beans.BeanUtils;

import com.qdlc.p2p.common.enums.EnumCardType;
import com.qdlc.p2p.dal.dto.CardRule;

/**
 * 卡片规则 Model
 *
 * @author Kaiju Zhao
 * @version V1.0.0
 * @date 2016-05-06
 */
public class CardRuleModel extends CardRule {

    /**
     * 搜索框输入字符串
     */
    private String searchName;

    /**
     * 获取开始时间
     */
    private String startTime;

    /**
     * 获取结束时间
     */
    private String endTime;

    /**
     * 当前页
     */
    private int page;

    /**
     * 每页记录数
     */
    private int rows;

    /**
     * 类型描述
     */
    private String typeStr;

    public String getSearchName() {
        return searchName;
    }

    public void setSearchName(String searchName) {
        this.searchName = searchName;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public void setTypeStr(String typeStr) {
        this.typeStr = typeStr;
    }

    public String getTypeStr() {
        return EnumCardType.getName(getType());
    }

    /**
     * CardRuleModel
     *
     * @param cardRule
     * @return CardRuleModel
     * @author Kaiju Zhao
     */
    public static CardRuleModel instance(CardRule cardRule) {
        CardRuleModel model = new CardRuleModel();
        BeanUtils.copyProperties(cardRule, model);
        return model;
    }

    /**
     * 根据Model返回实体原型
     *
     * @param model
     * @return CardRule
     * @author Kaiju Zhao
     */
    public static CardRule prototype(CardRuleModel model) {
        CardRule cardRule = new CardRule();
        BeanUtils.copyProperties(model, cardRule);
        return cardRule;
    }

}
